﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Community.CsharpSqlite
{
    /// <summary>
    ///  SQLite supports many different ways to resolve a constraint
    ///  error.  ROLLBACK processing means that a constraint violation
    ///  causes the operation in process to fail and for the current transaction
    ///  to be rolled back.  ABORT processing means the operation in process
    ///  fails and any prior changes from that one operation are backed out,
    ///  but the transaction is not rolled back.  FAIL processing means that
    ///  the operation in progress stops and returns an error code.  But prior
    ///  changes due to the same operation are not backed out and no rollback
    ///  occurs.  IGNORE means that the particular row that caused the constraint
    ///  error is not inserted or updated.  Processing continues and no error
    ///  is returned.  REPLACE means that preexisting database rows that caused
    ///  a UNIQUE constraint violation are removed so that the new insert or
    ///  update can proceed.  Processing continues and no error is reported.
    /// 
    ///  RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys.
    ///  RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the
    ///  same as ROLLBACK for DEFERRED keys.  SETNULL means that the foreign
    ///  key is set to NULL.  CASCADE means that a DELETE or UPDATE of the
    ///  referenced table row is propagated into the row that holds the
    ///  foreign key.
    /// 
    ///  The following symbolic values are used to record which type
    ///  of action to take.
    /// </summary>

    class OnConstraintError
    {
      
        public const int OE_None = 0; //#define OE_None     0   /* There is no constraint to check */

        public const int OE_Rollback = 1;
        //#define OE_Rollback 1   /* Fail the operation and rollback the transaction */

        public const int OE_Abort = 2; //#define OE_Abort    2   /* Back out changes but do no rollback transaction */
        public const int OE_Fail = 3; //#define OE_Fail     3   /* Stop the operation but leave all prior changes */

        public const int OE_Ignore = 4;
        //#define OE_Ignore   4   /* Ignore the error. Do not do the INSERT or UPDATE */

        public const int OE_Replace = 5;
        //#define OE_Replace  5   /* Delete existing record, then do INSERT or UPDATE */

        public const int OE_Restrict = 6;
        //#define OE_Restrict 6   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */

        public const int OE_SetNull = 7; //#define OE_SetNull  7   /* Set the foreign key value to NULL */
        public const int OE_SetDflt = 8; //#define OE_SetDflt  8   /* Set the foreign key value to its default */
        public const int OE_Cascade = 9; //#define OE_Cascade  9   /* Cascade the changes */

        public const int OE_Default = 99; //#define OE_Default  99  /* Do whatever the default action is */

    }
}
